sprintManagementProto = {
    initComponent : function()
    {
        sprintManagement.superclass.initComponent.call(this);
        this.initHandlers();
    }
    , initHandlers : function()
    {
        globals.bindHandlers(this.id, {
            reloadBtn: {item: this.reloadButton, fn : this.doReload , scope : this}
            ,nextSprintBtn: {item: this.nextSprintButton, fn : this.openNextSprintWizard , scope : this}
            ,addBtn: {item: this.addButton, fn : this.addSprint , scope : this}
        });
    }
    , doReload : function(){
        this.sprintGrid.getStore().reload();
    }
    , openNextSprintWizard : function()
    {
        sweatShop.log('TODO: open next sprint wizard', 3);
    }
    , addSprint : function()
    {
        Ext.Ajax.request({
            url: 'Sprint/add'
            ,success: this.afterAddSprint
            ,failure : globals.formSubmitFailed
            ,scope : this
        })
    }
    , afterAddSprint : function(response, request)
    {
        var result = Ext.util.JSON.decode(response.responseText);
        sweatShop.log(result.message , 1);
        theStore = this.sprintGrid.getStore();
        var r = new theStore.recordType(result.data[0]);
        theStore.insert(0,r);
    }
}
sprintManagement = Ext.extend(sprintManagementUi, sprintManagementProto);

function intToRoman(n) {
    var r = '';
    var d;
    var rn = new Array('IIII','V','XXXX','L','CCCC','D','MMMM');
    for (var i=0; i< rn.length; i++) {
        var x = rn[i].length+1;
        var d = n%x;
        r= rn[i].substr(0,d)+r;
        n = (n-d)/x;
    }

    return r;
}
